package com.jiegui.web.controller.busicess.wx;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jiegui.common.annotation.Log;
import com.jiegui.common.core.controller.BaseController;
import com.jiegui.common.core.domain.AjaxResult;
import com.jiegui.common.enums.BusinessType;
import com.jiegui.wx.domain.WechatGrouping;
import com.jiegui.wx.service.WechatGroupingService;
import com.jiegui.common.utils.poi.ExcelUtil;
import com.jiegui.common.core.page.TableDataInfo;

/**
 * 微信客服分组Controller
 * 
 * @author wuqicheng
 * @date 2021-12-14
 */
@RestController
@RequestMapping("/wx/wechatGrouping")
public class WechatGroupingController extends BaseController
{
    @Resource
    private WechatGroupingService wechatGroupingService;

    /**
     * 查询微信客服分组列表
     */
    @PreAuthorize("@ss.hasPermi('wx:wechatGrouping:list')")
    @GetMapping("/list")
    public TableDataInfo list(WechatGrouping wechatGrouping)
    {
        startPage();
        List<WechatGrouping> list = wechatGroupingService.selectWechatGroupingList(wechatGrouping);
        return getDataTable(list);
    }

    /**
     * 导出微信客服分组列表
     */
    @PreAuthorize("@ss.hasPermi('wx:wechatGrouping:export')")
    @Log(title = "微信客服分组", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WechatGrouping wechatGrouping)
    {
        List<WechatGrouping> list = wechatGroupingService.selectWechatGroupingList(wechatGrouping);
        ExcelUtil<WechatGrouping> util = new ExcelUtil<WechatGrouping>(WechatGrouping.class);
        return util.exportExcel(list, "微信客服分组数据");
    }

    /**
     * 获取微信客服分组详细信息
     */
    @PreAuthorize("@ss.hasPermi('wx:wechatGrouping:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wechatGroupingService.selectWechatGroupingById(id));
    }

    /**
     * 新增微信客服分组
     */
    @PreAuthorize("@ss.hasPermi('wx:wechatGrouping:add')")
    @Log(title = "微信客服分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WechatGrouping wechatGrouping)
    {
        return toAjax(wechatGroupingService.insertWechatGrouping(wechatGrouping));
    }

    /**
     * 修改微信客服分组
     */
    @PreAuthorize("@ss.hasPermi('wx:wechatGrouping:edit')")
    @Log(title = "微信客服分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WechatGrouping wechatGrouping)
    {
        return toAjax(wechatGroupingService.updateWechatGrouping(wechatGrouping));
    }

    /**
     * 删除微信客服分组
     */
    @PreAuthorize("@ss.hasPermi('wx:wechatGrouping:remove')")
    @Log(title = "微信客服分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wechatGroupingService.deleteWechatGroupingByIds(ids));
    }
}
